/**
 * Copyright (c) 2015-2030 by Beijing Yanlight Co., Ltd.
 * All rights reserved.
 */
package com.yanlight.support.wx.request;

import com.yanlight.support.http.AbstractRequest;
import com.yanlight.support.http.RequestBuilder;
import com.yanlight.support.wx.WxConstants;
import com.yanlight.support.wx.response.WxExchangeResponse;

/**
 * 
 * @author haolw
 * @time 2017/07/20
 */
public class WxExchangeRequest extends AbstractRequest<WxExchangeResponse> {
	private String appId;
	private String secret;
	private String code;
	private String grantType = "authorization_code";

	public String getAppId() {
		return appId;
	}

	public void setAppId(String appId) {
		this.appId = appId;
	}

	public String getSecret() {
		return secret;
	}

	public void setSecret(String secret) {
		this.secret = secret;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	@Override
	protected void execute(RequestBuilder builder) {
		builder.post().linkedHashMap();
		builder.addParam("appid", getAppId());
		builder.addParam("secret", getSecret());
		builder.addParam("code", getCode());
		builder.addParam("grant_type", grantType);
		builder.setUrl(WxConstants.WX_AUTH_ACCESS_TOKEN_URL);
	}
}
